from db import db

class Drug(db.Model):
    __tablename__ = 'drug'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(255),nullable=False)
    cover = db.Column(db.String(255),nullable=False)
    approval_number = db.Column(db.String(255),nullable=False)
    producer = db.Column(db.String(255),nullable=False)
    ingredient = db.Column(db.String(255),nullable=False)
    character = db.Column(db.String(255),nullable=False)
    guidance = db.Column(db.String(255),nullable=False)
    side_effects = db.Column(db.String(255),nullable=False)
    introduction = db.Column(db.String(255),nullable=False)

    def __init__(self,name,cover,approval_number,producer,ingredient,character,guidance,side_effects,introduction):
        self.name = name
        self.cover = cover
        self.approval_number = approval_number
        self.producer = producer
        self.ingredient = ingredient
        self.character = character
        self.guidance = guidance
        self.side_effects = side_effects
        self.introduction = introduction

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'cover': self.cover,
            'approvalNumber': self.approval_number,
            'producer': self.producer,
            'ingredient': self.ingredient,
            'character': self.character,
            'guidance': self.guidance,
            'sideEffects': self.side_effects,
            'introduction': self.introduction
        }